package com.sky.zzh.today.date;

import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import com.sky.zzh.R;

public class MainActivity extends Activity {

  protected Calendar mInitialTime, minTime = null, maxTime = null;
  protected int mLayoutID;
  protected TextView mTitleText;
  protected SliderContainer mContainer;
  protected int minuteInterval;
  private SliderContainer.OnTimeChangeListener onTimeChangeListener =
      new SliderContainer.OnTimeChangeListener() {
        // 时间改变的时候回调
        public void onTimeChange(Calendar time) {
          setTitle();
        }
      };

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.defaultdateslider);
    // findViewById(R.id.button).setOnClickListener(this);
    mInitialTime = Calendar.getInstance();
    mTitleText = (TextView) this.findViewById(R.id.dateSliderTitleText);
    mContainer = (SliderContainer) this.findViewById(R.id.dateSliderContainer);

    mContainer.setOnTimeChangeListener(onTimeChangeListener);
    mContainer.setMinuteInterval(minuteInterval);
    mContainer.setTime(mInitialTime);
    if (minTime != null) {
      mContainer.setMinTime(minTime);
    }
    if (maxTime != null) {
      mContainer.setMaxTime(maxTime);
    }


  }

  /**
   * @return The currently displayed time
   */
  protected Calendar getTime() {
    return mContainer.getTime();
  }

  public void setTime(Calendar c) {
    mContainer.setTime(c);
  }

  /**
   * This method sets the title of the dialog
   */
  protected void setTitle() {
    if (mTitleText != null) {
      final Calendar c = getTime();
      mTitleText.setText("dateSliderTitle" + String.format(": %te. %tB %tY", c, c, c));
      
      
      
      
      
    }
  }

}
